package threadPoolTest;


import java.util.concurrent.locks.LockSupport;

public class PauseThread {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            boolean flag = true;
            while (true) {
                for (int i = 0; i < 100; i++) {
                    try {
                        Thread.sleep(10);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.print("A");
                }
                System.out.println();
                if (flag) {
                    LockSupport.park();
                    flag = false;
                }
            }
        });
        Thread t2 = new Thread(() -> {
            while (true) {
                for (int i = 0; i < 100; i++) {
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.print("B");
                }
                System.out.println();
            }
        });
        t1.start();
        t2.start();
        Thread.sleep(1000 * 5);
        LockSupport.unpark(t1);
        System.out.println("111");
    }
}
